package com.aiguigu.test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Alarm implements Subject {
    List<Observer> observers = new ArrayList<>();

    @Override
    public void register(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void unregister(Observer observer) {
          if (!observers.isEmpty()&&observers.contains(observer)){
              observers.remove(observer);
          }
    }

    @Override
    public void sendMessage(String message) {
        for (Observer observer:observers){
            observer.alarm(message);
            observer.smoke(message);
        }
    }


}
